package com.zhz.lib.project.ibatis.ibatis;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.zhz.lib.project.ibatis.daointerface.CustomDAO;
import com.zhz.lib.project.ibatis.dataobject.Custom;

/**
 * @author LiWei <a href="mailto:liwei2672@gmail.com">liwei2672@gmail.com</a>
 * @version 创建时间：2010-5-12 下午08:45:43
 * 
 */
public class CustomDAOImpl extends SqlMapClientDaoSupport implements CustomDAO {
    private static Logger logger = Logger.getLogger(CustomDAOImpl.class);

    public Custom getCustomById(String id) {
        return (Custom) getSqlMapClientTemplate().queryForObject("selectCustomById", id);

    }

    public List getCustomBySortType(String sortType) {
        List list = null;
        try {
            list = getSqlMapClientTemplate().queryForList("getCustomBySortType", sortType);
        } catch (DataAccessException e) {
            logger.error("getCustomBySortType发生异常", e);
        }
        return list;
    }

    @SuppressWarnings("unchecked")
    public void customHitPlusOne(String id) {
        Map map = new HashMap<String, Integer>();
        map.put("customID", id);
        getSqlMapClientTemplate().update("customHitPlusOne", map);
    }
}
